﻿/**********************************************************
 ●项目：Smartkernel
 ●公司：智能核心信息技术研发中心
 ●作者：曹艳白
 ●邮箱：caoyanbai@gmail.com
 ●创建：2008-08-10
**********************************************************/
using System.Diagnostics;

namespace Smartkernel.Log
{
    /// <summary>
    /// 系统事件日志操作功能
    /// </summary>
    public static class SmartEventLoger
    {
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="smartLogLevelType">事件日志的级别</param>
        /// <param name="message">日志信息的内容</param>
        /// <param name="path">日志的来源，用于区分不同的日志，例如：Smartkernel.Framework.Error</param>
        public static void Write(string message, string path, SmartLogLevelType smartLogLevelType)
        {
            using (EventLog eventLog = new EventLog())
            {
                eventLog.Source = path;
                eventLog.WriteEntry("[" + smartLogLevelType.ToString() + "]：" + message, EventLogEntryType.Error);
            }
        }
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="message">日志信息的内容</param>
        /// <param name="path">日志的来源，用于区分不同的日志，例如：Smartkernel.Framework.Error</param>
        public static void Write(string message, string path)
        {
            Write(message, path, SmartLogLevelType.Middle);
        }
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="smartLogLevelType">事件日志的级别</param>
        /// <param name="message">日志信息的内容</param>
        public static void Write(string message, SmartLogLevelType smartLogLevelType)
        {
            Write(message, "Smartkernel.Framework.Error", smartLogLevelType);
        }
        /// <summary>
        /// 写日志
        /// </summary>
        /// <param name="message">日志信息的内容</param>
        public static void Write(string message)
        {
            Write(message, "Smartkernel.Framework.Error", SmartLogLevelType.Middle);
        }
    }
}
